#ifndef CAMTHREAD_H_
#define CAMTHREAD_H_

#include "wx/wxprec.h"
#include "wx/thread.h"

#ifndef  WX_PRECOMP
  #include "wx/wx.h"
#endif //precompiled headers

#include <iostream>
using namespace std;



class wxCamViewWindow;
class MainFrame;

/**
 * \brief Thread used to obtain video from the camera.
 * 
 * The Thread is implemented according on the wxwidgets model of using threads.
 */
   
class CamThread : public wxThread
{
public:

	/**
	 * \brief Constructor
	 * 
	 * \param frame: the main frame of the application, used to control the thread via the flags.
	 */
	CamThread( MainFrame *frame );
	
	/**
	 * \brief Destructor
	 */
	~CamThread( );

	/**
	 * \brief Function called when the thread is started.
	 * 
	 * This function implements the tasks to be executed while the thread is still alive. It will check if
	 * the camera of the frame is on and the isPaused flag of the frame is cleared. Then it will continuosly
	 * query images to be shown on camView.
	 */
	virtual void *Entry();
	
	/**
	 * \brief Called when the thread exits.
	 */
	virtual void OnExit();

// data
public:
	
	/**
	 * \brief The main Frame of the application.
	 */
    MainFrame		*frame;
	
	/**
	 * \brief The window where the queried images will be shown.
	 */
	wxCamViewWindow* camView;

	/**
	 * \brief flag indicating if the thread is still alive or not.
	 */
	unsigned char	alive;

// private data
private:
	/**
	 * \brief Process syncronizer/locker
	 */
	wxMutex *m_pMutex;

};
#endif /*CAMTHREAD_H_*/
